package com.xinlu.user.action;

import com.xinlu.derek.common.BaseAction;
import com.xinlu.derek.common.BaseForm;
import com.xinlu.persistence.Users;
import com.xinlu.persistence.Xxtx;
import com.xinlu.user.bo.XxtxBo;
import com.xinlu.user.form.XxtxForm;

public class XxtxAction extends BaseAction {

	XxtxForm fr = new XxtxForm();
	private XxtxBo xxtxBo;

	public void setFr(XxtxForm fr) {
		this.fr = fr;
	}

	public void setXxtxBo(XxtxBo xxtxBo) {
		this.xxtxBo = xxtxBo;
	}

	@Override
	public String doExecute() throws Exception {
		return null;
	}

	@Override
	public void formInit() {
	}

	@Override
	public BaseForm getModel() {
		return fr;
	}

	/**
	 * 加载页面
	 * 
	 * @return
	 */
	public String loadPage() {
		Users crtUser = (Users) getSession().getAttribute("userinfo");
		Xxtx xxtx = xxtxBo.loadXxtx(crtUser.getUsername());

		fr.setCktx(xxtx.getCktx() == 1 ? "true" : "false");
		fr.setQktx(xxtx.getQktx() == 1 ? "true" : "false");
		fr.setFdtx(xxtx.getFdtx() == 1 ? "true" : "false");
		fr.setPjtx(xxtx.getPjtx() == 1 ? "true" : "false");

		return "xxtx";
	}

	/**
	 * 修改消息提醒
	 * 
	 * @return
	 */
	public String changeXxtx() {
		Users crtUser = (Users) getSession().getAttribute("userinfo");
		xxtxBo.update(crtUser.getUsername(), fr.getCktx(), fr.getQktx(), fr.getFdtx(), fr.getPjtx());

		return "xxtx";
	}

}
